package dongze.com.ckdj.adapter;

import android.databinding.DataBindingUtil;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import dongze.com.ckdj.R;
import dongze.com.ckdj.databinding.MassLossPictureItemBinding;
import dongze.com.ckdj.databinding.model.MassLossImageItemModel;

/**
 * Created by fanqwz on 2017/9/14.
 */

public class ImageListAdapter extends RecyclerView.Adapter<ImageListAdapter.Holder> {
    MassLossImageItemModel[] models;
    public ImageListAdapter(MassLossImageItemModel[] models) {
        this.models = models;
    }

    @Override
    public Holder onCreateViewHolder(ViewGroup parent, int viewType) {
        MassLossPictureItemBinding binding1 = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.mass_loss_picture_item, parent, false);
        return new Holder(binding1.getRoot(), binding1);
    }

    @Override
    public void onBindViewHolder(Holder holder, int position) {
        holder.binding.setMassLossImageItem(models[position]);
    }

    @Override
    public int getItemCount() {
        return models.length;
    }

    public static class Holder extends RecyclerView.ViewHolder {
        MassLossPictureItemBinding binding;
        public Holder(View itemView, MassLossPictureItemBinding binding) {
            super(itemView);
            this.binding = binding;
        }
    }
}
